﻿using System;
using UnityEngine;

// Token: 0x02000024 RID: 36
public class RangerScript : MonoBehaviour
{
	// Token: 0x060000A4 RID: 164 RVA: 0x0000F2B3 File Offset: 0x0000D4B3
	private void Start()
	{
		this.body = base.GetComponent<BodyScript>();
		this.body.Pickup(null);
	}

	// Token: 0x060000A5 RID: 165 RVA: 0x0000F2D0 File Offset: 0x0000D4D0
	private void Update()
	{
		this.workTime -= Time.deltaTime;
		if (this.body.held && !this.body.heldFirearm)
		{
			this.body.held.damageMult = 1.7f;
		}
		if (Input.GetKeyDown(KeyCode.G) && this.body.held && this.workTime < 0f && !this.body.heldFirearm)
		{
			this.workTime = 1.5f;
			this.working = true;
			Sound.Play(Resources.Load<AudioClip>("Sounds/craftGun"), this.body.held.transform.position, false, false, 1f);
		}
		if (this.workTime > 0f && this.body.hitStun < 0.1f)
		{
			this.body.hitStun = 0.1f;
		}
		if (this.workTime < 0f && this.working)
		{
			this.working = false;
			if (this.body.held)
			{
				Object.Destroy(this.body.held.gameObject);
				GameObject gameObject;
				if (this.body.held.durability < 350f)
				{
					gameObject = Object.Instantiate<GameObject>(this.weapons[0], this.body.held.transform.position, this.body.held.transform.rotation);
				}
				else if (this.body.held.durability < 600f)
				{
					gameObject = Object.Instantiate<GameObject>(this.weapons[1], this.body.held.transform.position, this.body.held.transform.rotation);
				}
				else if (this.body.held.durability < 800f)
				{
					gameObject = Object.Instantiate<GameObject>(this.weapons[2], this.body.held.transform.position, this.body.held.transform.rotation);
				}
				else
				{
					gameObject = Object.Instantiate<GameObject>(this.weapons[3], this.body.held.transform.position, this.body.held.transform.rotation);
				}
				this.body.DropWeapon();
				this.body.pickupCooldown = -1f;
				this.body.PickupSpecific(gameObject.GetComponent<WeaponScript>());
				gameObject.GetComponent<FirearmScript>().ammo = Mathf.RoundToInt((float)gameObject.GetComponent<FirearmScript>().ammo * 1.5f);
				gameObject.GetComponent<FirearmScript>().maxAmmo = Mathf.RoundToInt((float)gameObject.GetComponent<FirearmScript>().ammo * 1.5f);
			}
		}
	}

	// Token: 0x0400017F RID: 383
	private BodyScript body;

	// Token: 0x04000180 RID: 384
	private float workTime;

	// Token: 0x04000181 RID: 385
	private bool working;

	// Token: 0x04000182 RID: 386
	public GameObject[] weapons;
}
